home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
UNIX
/
C
/
C-STYLE
/
STYLE
< prev
next >
Wrap
Text File
|
1992-11-23
|
1KB
|
56 lines
TMP1=/tmp/style1$$
TMP2=/tmp/style2$$
RESULTS=/tmp/stat$$
LIB=.
trap "rm -f $TMP1 $TMP2 $RESULTS; trap ''0; exit" 0 1 2 13 15
for i
do
echo; echo 'Style analysis of ' $i
if test -r $i
then : --- count comment lines and total lines.
awk -f $LIB/style.cnt.awk $i > $RESULTS
:
: --- replace tabs by spaces
: --- convert to lower case
: --- fix strings and comment delimiters
: --- remove comments
:
$LIB/style.detab < $i |\
tr "[A-Z]" "[a-z]" |\
sed -f $LIB/style.str.sed |\
sed -n -f $LIB/style.com.sed > $TMP1
:
: --- sort program words
:
tr -cs "a-z0-9_" "\012" < $TMP1 |\
sed -n '/^[a-z]/p' |\
sort -u > $TMP2
:
: --- find length of user identifiers.
:
comm -23 $TMP2 $LIB/style.dict |\
awk >> $RESULTS \
'{totl += length}; \
END {print "NL ";\
if (NR) print (totl/NR); else print 0;\
print "ID " NR }'
:
: --- count variety of reserved woeds
:
comm -12 $TMP2 $LIB/style.dict |\
(echo "RW" `wc -l`) >> $RESULTS
:
: --- produce remaining metrics
:
awk -f $LIB/style.met.awk $TMP1 >> $RESULTS
:
: --- and analyse
:
$LIB/style.stan < $RESULTS
else echo " Cannot read"; echo ""
fi
done